/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"

#include "非线性动画条.h"


static C_StrKey分配器 g轨道层名称ID;


void f_anim_新建轨道条() {

}



S_轨道层* f_anim_创建轨道层(DEF_WString name) {
	name = g轨道层名称ID.f_Gen(name);

	S_轨道层* 层 = new S_轨道层;
	层->name = name;

	return 层;
}

void f_anim_销毁轨道层(S_轨道层* 层) {
	for (auto& e : 层->m_层采样条) {
		f_anim_销毁采样条(e);
	}

	g轨道层名称ID.f_Move(层->name);
	delete 层;
}

S_TrackSample* f_anim_创建采样条(E_采样条类型 条类型) {
	S_TrackSample* ts = (S_TrackSample*)malloc(sizeof(S_TrackSample));
	
	ts->m_Address_Point = 0;
	ts->m_DataType = 0;

	ts->m_SampleLength = 0;
	ts->m_SampleStart = 0;
	ts->m_SampleType = 条类型;

	ts->m_Start = 0;
	
	return ts;
}

void f_anim_销毁采样条(S_TrackSample* 采样条) {
	free(采样条);
}

int32 f_anim_时间转帧(S_时间线* 时间线) {
	return 时间线->m_时间 * 时间线->m_帧率;
}

int32 f_anim_时间转帧(S_时间线* 时间线, float64 时间) {
	return 时间 *  时间线->m_帧率;
	//return 时间 * (1000 / 时间线->m_帧率);
}

bool f_anim_帧是否在采样条内(const S_TrackSample* ts, int32 帧) {
	if (帧 >= ts->m_SampleStart && 帧 < ts->m_SampleStart + ts->m_SampleLength) {
		return true;
	}
	return false;
}








